package init

import (
	"fmt"
	"github.com/elastic/go-elasticsearch/v7"
	"log"
	"user_srv/basic/config"
)

func InitElasticSearch() {
	var err error
	data := config.AppConf.ElasticSearch
	data_host := fmt.Sprintf("%s:%d", data.Host, data.Port)
	cfg := elasticsearch.Config{
		Addresses: []string{
			"http://" + data_host,
		},
		// ...
	}
	config.Es, err = elasticsearch.NewClient(cfg)
	if err != nil {
		panic("es init failed")
	} else {
		log.Println("es init success")
	}
}
